package com.zlp.controller;

import com.zlp.service.PaymentService;
import com.zlp.utils.RedisLock;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ：ZouLiPing
 * @description：多线程测试
 * @date ： 2019/8/15 15:41
 */
@Component
class ExecService extends Thread{

    @Resource
    private RedisLock redisLock;

    @Override
    public void run() {
        textThread();
    }


    public void textThread() {

        System.out.println(Thread.currentThread().getName() + "线程 ,获取锁失败，原因时间超时!!!");
        try {
            Thread.sleep(30);
        } catch (Exception e) {

        }
    }



}
@RestController
public class ThreadPaymentTest{


    @GetMapping("getThreadTest")
    public String getThreadTest(){
        PaymentService paymentService = new PaymentService();
        for (int i = 0; i <50 ; i++) {
            ExecService threadPaymentTest = new ExecService();
            threadPaymentTest.start();
        }
        return "多线程测试";
    }

}
